namespace :crp do
  desc "Migrate the database through scripts in db/user with database config session \"user\" in config/database.yml. Target specific version with VERSION=x"
  task :user_migrate => :environment do
    ActiveRecord::Base.establish_connection :user
    ActiveRecord::Migrator.migrate("db/user/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
  end
  desc "Migrate the database weekly"
  task :weekly_migrate => :environment do
    ActiveRecord::Base.establish_connection :weekly
    ActiveRecord::Migrator.migrate("db/weekly/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
  end
  desc "Migrate the database pgweekly"
  task :pgweekly_migrate => :environment do
    ActiveRecord::Base.establish_connection :pgweekly
    ActiveRecord::Migrator.migrate("db/weekly/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
  end
end
